package controllers;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import models.Idea;

public class OrderIdeaByRating implements Comparator<Idea> {

	@Override
	public int compare(Idea u1, Idea u2) {
		if(u1.rating < u2.rating)
			return -1;
		if(u1.rating > u2.rating)
			return 1;
		return 0;
	}


	public static void sort(ArrayList<Idea> ideas){
		Collections.sort(ideas, new OrderIdeaByRating());
	}

}